package com.vitalfit.handler;

import com.vitalfit.model.dto.HandleDTO;
import com.vitalfit.model.entity.user.User;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class HandlerChainManager<T extends User> {
    private final List<UserHandler<T>> handlers = new ArrayList<>();

    public void addHandler(UserHandler<T> handler) {
        handlers.add(handler);
    }

    public void handle(T user, HandleDTO handleDTO) {
        for (UserHandler<T> handler : handlers) {
            handler.handle(user, handleDTO);
        }
    }
}